package day8.pm;

public class Exec {
    public static void main(String[] args) {
        // 按照个位数 + 十位数的和进行升序排序
        int[] data = {90, 66, 34, 76, 23, 34};
        for(int i = 0; i < data.length; i++){
            int min = sum(data[i]);
            for(int j = i; j < data.length; j ++){
                if(sum(data[j]) < min){
                    min = data[j];
                    data[j] = data[i];
                    data[i] = min;
                }
            }
        }
        for(int x : data){
            System.out.print(sum(x) + "------");
            System.out.println(x);
        }
    }

    // 23423455
    public static int sum(int num){
        if(num <= 9) return num;
        int res = num % 10;
        // 考虑最后一位为0的情况
        while(num/10 != 0){
            num /= 10;
            res += num % 10;
        }
        return res;
    }
}
